fprintf('-------二阶环节离散化--------\n');
fprintf('\n采样周期为(秒):\n');

f = 100;
width = 20;
deepth = 0.5;

t=1e-4;
b0=2*pi*f;
b1=width*2*pi*deepth;
b2=width*2*pi;

G=tf([1 b1 b0^2],[1 b2 b0^2])
[num,den]=c2dm([1 b1 b0^2],[1 b2 b0^2],t,'tustin')%prewarp,,tustin

fprintf('\n最终结果为:\n');







fprintf('y(n)=y3*y(n-1)+u2*u(n)+u1*u(n-1)+u0*u(n-2)\n');







fprintf('y1=%14.12f\n',-den(2));
fprintf('y0=%14.12f\n',-den(3));
fprintf('u2=%14.12f\n',num(1));
fprintf('u1=%14.12f\n',num(2));
fprintf('u0=%14.12f\n',num(3));

fprintf('\n复制以下部分:\n');
fprintf('%14.12f,',-den(2));
fprintf('%14.12f,',-den(3));
fprintf('%14.12f,',num(1));
fprintf('%14.12f,',num(2));
fprintf('%14.12f\n',num(3));

% pause;
dbode(num,den,t);
% zoom on;
grid on;

hold on;